<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();
	String BasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>川轻化健身房</title>
  <meta name="description" content="Ela Admin - HTML5 Admin Template">
    <meta name="viewport" content="width=device-width, initial-scale=1">



<link href="<%=BasePath%>/static/time/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/normalize.css">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/bootstrap.min.css">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/themify-icons.css">
<link rel="stylesheet" href="<%=BasePath%>/static/assets/css/style.css">
<link rel="stylesheet" href="<%=BasePath%>/static/vendor/bootstrap/css/bootstrap.css" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800' rel='stylesheet' type='text/css'>
<script type="text/javascript"
	src="<%=BasePath%>/static/vendor/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript"
	src="<%=BasePath%>/static/vendor/bootstrap/js/bootstrap.min.js"></script>



</head>

<body>
<div class="modal fade" id="readerUpdateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h1 class="modal-title" align="center"><strong>教练信息编辑</strong></h1>

                <form class="fh5co-form" id="defaultForm">

                    <h3 >教练ID</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text" name="coachID" class="form-control" id="coachID"  disabled="true" >

                        </div>
                    </div>

                    <h3 >教练姓名</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text" name="name" class="form-control" id="name">
                        </div>
                    </div>


                    <h3 >口号</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="slogan" >
                        </div>
                    </div>
                    <h3 >擅长</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="able" >
                        </div>
                    </div>
                    <h3 >教龄</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="tyear" >
                        </div>
                    </div>
                    <h3 >身高</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="height" >
                        </div>
                    </div>
                    <h3 >体重</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="weight" >
                        </div>
                    </div>
                    <h3 >年龄</h3>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon"><i class="fa fa-user"></i></div>
                            <input type="text"  class="form-control" id="age" >
                        </div>
                    </div>

                </form>

                <div id="btn-div">
                    <button type="button" class="btn btn-warning btn-lg btn-block" id="validateBtn" name="validateBtn">更新</button>
                </div>
            </div>
        </div>
    </div>
</div>



	<!-- Left Panel -->
	    <!-- Left Panel -->
    <aside id="left-panel" class="left-panel">
        <nav class="navbar ">
            <div id="main-menu" class="main-menu ">
                  <ul class="nav navbar-nav">
					<li class="menu-item "><a href="../coach/toindex" class="dropdown-toggle"><i
							class="menu-icon fa fa-home"></i>主页</a></li>
					<li class="menu-title">会员管理</li>
					<!-- /.menu-title -->
					<li class="menu-item"><a href="../coach/tomember"
						class="dropdown-toggle"> <i class="menu-icon  fa fa-search"></i>查看会员信息
					</a></li>

				<li class="menu-title">个人管理</li>
					<!-- /.menu-title -->
					<li class="menu-item active"><a href="../coach/toinfo"
						class="dropdown-toggle"> <i class="menu-icon fa   fa-users"></i>查看个人信息
					</a></li>



					
					
				</ul>
            </div><!-- /.navbar-collapse -->
        </nav>
    </aside>
    <!-- /#left-panel -->
    <!-- Right Panel -->
    <div id="right-panel" class="right-panel">
        <!-- Header-->
        <header id="header" class="header">
            <div class="top-left">
              <div class="navbar-header">
                   <a class="navbar-brand" href="../admins"><p style="font-size:30px" >教练专属页面</p></a>

                   <a id="menuToggle" class="menutoggle"><h4><i class="fa fa-bars fa-lg"></i></h4></a>
                </div>
            </div>
            <div class="top-right">
                <div class="header-menu">
                <div class="header-left">

					</div>
                    <div div class="user-area dropdown float-right">	
                   <span class="text-success"> <%HttpSession name = request.getSession(); %>
                                            <%=name.getAttribute("name") %>欢迎你！</span>
                                              </div>


                </div>
            </div>
        </header>

        <div class="content">

            <div class="animated fadeIn">
                <div class="card">
                    <h1 class="text-center">个人信息管理</h1>


                        <div class="card-body">
                            <table class="table table-striped table-bordered dateTable no-footer" id="reader_table">
                                <thead>
                                <tr >
                                    <th><h3 align="center">教练id</h3></th>
                                    <th><h3 align="center">姓名</h3></th>
                                    <th><h3 align="center">头像</h3></th>
                                    <th><h3 align="center">年龄</h3></th>
                                    <th><h3 align="center">身高</h3></th>
                                    <th><h3 align="center">体重</h3> </th>
                                    <th><h3 align="center">教龄</h3></th>
                                    <th><h3  class="text-warning" align="center">操作</h3></th>
                                </tr>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>

                        </div>
                    </div>
                    <div class="row">
                        <!--分页文字信息  -->
                        <div class="col-md-6" ><p class="lend" id="page_info_area" class="text-success"></p></div>
                        <!-- 分页条信息 -->
                        <div class="col-md-6" i><h2 class="lend" id="page_nav_area"></h2></div>
                    </div>


                </div>
            </div>
        </div>
	</div>

    <script src="<%=BasePath%>/static/assets/js/vendor/jquery-2.1.4.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/popper.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/bootstrap.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/jquery.matchHeight.min.js"></script>
    <script src="<%=BasePath%>/static/assets/js/main.js"></script>
    <script type="text/javascript" src="<%=BasePath%>/static/time/jquery/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="<%=BasePath%>/static/time/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=BasePath%>/static/time/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="<%=BasePath%>/static/time/js/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
    var coachinfo;
    <%HttpSession hs = request.getSession(); %>
    var hscid="<%=hs.getAttribute("cid")%>";
    $(function () {
        $.ajax({
            url:"../coach/readCoachinfo",
            type:"GET",
            data:{
                cid:hscid
            },
            success:function (data) {
                coachinfo = data.data;
                build_table(coachinfo);
            }

        });
    });
    function build_table(coachinfo) {
        $("#reader_table tbody").empty();

            var readCid = $("<td></td>").addClass("classCid").append(coachinfo.cid);
            var readName = $("<td></td>").addClass("className").append(coachinfo.name);
            var readPicture = $("<td></td>").addClass("classAvatar").append("<img src='<%=BasePath%>"+coachinfo.picture+"' width='50' height='50' >");
            var readAge = $("<td></td>").addClass("classAge").append(coachinfo.age);
            var readHeight = $("<td></td>").addClass("classAge").append(coachinfo.height);
            var readWeight = $("<td></td>").addClass("classAge").append(coachinfo.weight);
            var readTyear = $("<td></td>").addClass("classTyear").append(coachinfo.tyear);

            var editBtn = $("<button></button>").addClass("btn btn-success btn-lg edit_btn")
                .append($("<span></span>").addClass("glyphicon glyphicon-pencil")).append("编辑");




            var btnTd = $("<td></td>").append(editBtn);

            $("<tr align='center'></tr>")
                .append(readCid)
                .append(readName)
                .append(readPicture)
                .append(readAge)
                .append(readHeight)
                .append(readWeight)
                .append(readTyear)
                .append(btnTd)
                .appendTo("#reader_table tbody");

    }
    $(document).on("click",".edit_btn",function () {
        $("#coachID").val(coachinfo.cid);
        $("#name").val(coachinfo.name);
        $("#picture").val(coachinfo.picture);
        $("#able").val(coachinfo.able);
        $("#slogan").val(coachinfo.slogan);
        $("#tyear").val(coachinfo.tyear);
        $("#height").val(coachinfo.height);
        $("#weight").val(coachinfo.weight);
        $("#age").val(coachinfo.age);
        $("#readerUpdateModal").modal({
            backdrop:"static"
        });
    });
    $(document).on("click","#validateBtn",function () {
       var cid = $("#coachID").val();
       var name = $("#name").val();

        var able=  $("#able").val();
        var slogan =  $("#slogan").val();
        var tyear =  $("#tyear").val();
        var height = $("#height").val();
        var weight =  $("#weight").val();
        var age =  $("#age").val();
        $.ajax({
            url:"../coach/updataCoachinfo",
            data:{
                cid:cid,
                name:name,
                able:able,
                slogan:slogan,
                tyear:tyear,
                height:height,
                weight:weight,
                age:age
            },
            dataType:"JSON",
            success:function (data) {
                if(data.status == 200){
                    alert("更新成功");
                    window.location.href="../coach/toinfo";
                }
            }

        })
    })
</script>

</body>
</html>
